<!--loading组件-->
<template>
  <view>
    <view v-show="show" class="uni-mask mask" :style="{ background: maskBackground }"></view>
  </view>
</template>

<script>
export default {
  props: {
    titleText: {
      type: String,
      default: '正在加载中'
    },
    show: {
      type: Boolean,
      default: true
    },
    mask: {
      type: Boolean,
      default: false
    },
    maskBackground: {
      type: String,
      default: ''
    },
    maskClass: {
      type: String,
      default: ''
    },
    maskStyle: {
      type: Object,
      default: () => {
        return {}
      }
    },
  },
  data () {
    return {
    }
  },
  created() {

  },
  watch: {
    show (val) {
      if (val) {
        uni.showLoading({ title: this.titleText })
      } else {
        uni.hideLoading()
      }
    }
  },
  mounted() {
    if (this.show) {
      uni.showLoading({ title: this.titleText })
    } else {
      uni.hideLoading()
    }
  },
  methods: {
  }
}
</script>

<style lang="scss" scoped>
.mask {
  width: 100vw;
  height: 100vh;
  position: fixed;
  background: rgba(0,0,0,0.3);
  top: 0;
  left: 0;
  z-index: 9999;
}
</style>